
*This code must be run within the main do file. It will not run correctly on its own. 

	use "$data/Replication_data.dta", replace
		merge 1:1 fips year using "$data/ac_data.dta"
			assert _merge==3
			drop _merge
	
	label var totalac "Total AC(\%)"
	local a_dry = " prec_dry below40_dry FND_Max40to45_dry FND_Max45to50_dry FND_Max50to55_dry FND_Max55to60_dry FND_Max60to65_dry FND_Max75to80_dry  FND_Max65to70_dry "
	
	local a_wet = " prec below40_wet FND_Max40to45_wet FND_Max45to50_wet FND_Max50to55_wet FND_Max55to60_wet FND_Max60to65_wet FND_Max75to80_wet  FND_Max65to70_wet "
	
	local b_dry = "totalac c.Dividends#c.prec prec    c.Dividends#c.below40_dry c.Dividends#c.FND_Max40to45_dry c.Dividends#c.FND_Max45to50_dry c.Dividends#c.FND_Max50to55_dry c.Dividends#c.FND_Max55to60_dry c.Dividends#c.FND_Max60to65_dry c.Dividends#c.FND_Max75to80_dry  below40_dry FND_Max40to45_dry FND_Max45to50_dry FND_Max50to55_dry FND_Max55to60_dry FND_Max60to65_dry FND_Max75to80_dry FND_Max65to70_dry c.Dividends#c.FND_Max65to70_dry"	
	
	
	local b_wet = "totalac prec c.Dividends#c.prec  c.Dividends#c.below40_wet c.Dividends#c.FND_Max40to45_wet c.Dividends#c.FND_Max45to50_wet c.Dividends#c.FND_Max50to55_wet c.Dividends#c.FND_Max55to60_wet c.Dividends#c.FND_Max60to65_wet c.Dividends#c.FND_Max75to80_wet  below40_wet FND_Max40to45_wet FND_Max45to50_wet FND_Max50to55_wet FND_Max55to60_wet FND_Max60to65_wet FND_Max75to80_wet  FND_Max65to70_wet c.Dividends#c.FND_Max65to70_wet"	

//Dry bulb regression
	rename (days90plus_dry FND_Max85to90_dry FND_Max80to85_dry  ) (days90plus FND_Max85to90 FND_Max80to85 )

			rename Dividends x
				foreach n in mean_Div4 { 
					rename `n' Dividends
					label var lny_nonag "`n'"
					label var Dividends "Dividends"
					
					reghdfe lny_nonag days90plus FND_Max85to90 FND_Max80to85 Dividends c.Dividends#c.days90plus c.Dividends#c.FND_Max85to90 c.Dividends#c.FND_Max80to85 `b_dry', absorb(i.fips i.year i.state#c.year) cluster(i.fips#i.year) 
					est store m1	
					rename Dividends `n'
				}
			
			rename x Dividends	
	rename (days90plus FND_Max85to90 FND_Max80to85 ) (days90plus_dry FND_Max85to90_dry FND_Max80to85_dry  ) 
	
//Wet bulb regression	
	rename (days90plus_wet FND_Max85to90_wet FND_Max80to85_wet  )  (days90plus FND_Max85to90 FND_Max80to85 ) 

						
		
//Regressions with various measures of Dividends
		local i=2	
		rename Dividends x
		foreach n in  mean_Div4 { 
			rename `n' Dividends
			label var lny_nonag "`n'"
			label var Dividends "Dividends"
			
			reghdfe lny_nonag days90plus FND_Max85to90 FND_Max80to85  c.Dividends#c.days90plus c.Dividends#c.FND_Max85to90 c.Dividends#c.FND_Max80to85 Dividends `b_wet', absorb(i.fips i.year i.state#c.year) cluster(i.fips#i.year) 
				est store m`i'
			local i=`i'+1
			rename Dividends `n'
		}
	
	rename (days90plus FND_Max85to90 FND_Max80to85 x ) (days90plus_wet FND_Max85to90_wet FND_Max80to85_wet Dividends ) 
	
	g days90plus=0
	g FND_Max80to85=0
	g FND_Max85to90=0
	label var FND_Max85to90 "Days \$85-90\degree\$F"
	label var FND_Max80to85 "Days \$80-85\degree\$F"
	label var days90plus "Days \$>90\degree\$F"
	label var Dividends "Dividends"
	//Main table
	esttab m2 using "$Table/SITable3.tex", replace f ///
		label booktabs b(5) p(5) eqlabels(none) alignment(S S) mtitles( "\shortstack{Heat Index,  5 yr. Avg}" )  ///
		keep(days90plus  FND_Max85to90 FND_Max80to85 Dividends c.Dividends#c.days90plus  c.Dividends#c.FND_Max85to90 c.Dividends#c.FND_Max80to85 totalac ) ///
		star(* 0.10 ** 0.05 *** 0.01) ///
		refcat(, nolabel) ///
		stats(N r2, fmt(%9.0fc 2) layout("\multicolumn{1}{c}{@}" "\multicolumn{1}{S}{@}") labels(`"Observations"' `"\(R^{2}\)"' `"County FE"' `"Month FE"' `"Year FE"' `"State $\times\$ Year"' `"State $\times\$ Year$^{2}\$"' `"State $\times\$ Year$^{3}\$"'))
